package cn.it.hbtt.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class BaseDAO {

    public Connection getConnection(){
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            String url="jdbc:mysql://localhost:3306/myschool?serverTimezone=Asia/Shanghai&enconding=UTF-8";
            String user="root";
            String pwd="123456";
            Connection conn = DriverManager.getConnection(url, user, pwd);
            return  conn;

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(new BaseDAO().getConnection());
    }
}
